﻿using System;

using Rarous.TexyNet;

using Xunit;

namespace Rarous.TexyNet.Test {

  /// <summary>
  /// This is a test class for ModifierSpec and is intended
  /// to contain all ModifierSpec Unit Tests
  /// </summary>
  public class ModifierSpec {

    private static Modifier GetModifier() {
      string toolTip = "text";
      string cssClass = "bigger";
      return new Modifier(toolTip, cssClass);
    }

    /// <summary>
    /// A test for ToolTipTest
    /// </summary>
    [Fact]
    public void Modifier_ToolTip_PropertyBehavior() {
      Modifier target = new Modifier();
      string expected = "text";
      target.ToolTip = expected;

      Assert.Equal(expected, target.ToolTip);

      expected = String.Empty;
      target.ToolTip = expected;

      Assert.Equal(expected, target.ToolTip);
    }

    /// <summary>
    /// A test for IsNotEmptyTest
    /// </summary>
    [Fact]
    public void Modifier_IsNotEmpty() {
      Modifier target = new Modifier();

      Assert.False(target.IsNotEmpty);

      target.ToolTip = "text";

      Assert.True(target.IsNotEmpty);
    }

    /// <summary>
    /// A test for ToStringTest
    /// </summary>
    [Fact]
    public void Modifier_ToString() {
      Modifier target = GetModifier();
      target.AddStyle("color", "black");

      Assert.Equal(" .(text)[bigger]{color:black}", target.ToString());
    }

    /// <summary>
    /// A test for ToStringTest
    /// </summary>
    [Fact]
    public void Modifier_ToString_Empty() {
      Modifier target = new Modifier();

      Assert.Equal(String.Empty, target.ToString());
    }

    /// <summary>
    /// A test for AddStyleTest1
    /// </summary>
    [Fact]
    public void Modifier_AddStyle_CanAdd() {
      Modifier target = new Modifier();
      target.AddStyle("color", "black");

      Assert.Equal("color:black", target.Style);

      target.AddStyle("border", "0");

      Assert.Equal("color:black;border:0", target.Style);
    }

    /// <summary>
    /// A test for AddCssClassTest
    /// </summary>
    [Fact]
    public void Modifier_AddCssClass_CanAdd() {
      Modifier target = new Modifier();
      string expected = "bigger";
      target.AddCssClass(expected);

      Assert.Equal(expected, target.CssClass);

      expected = "bolder";
      target.AddCssClass(expected);

      Assert.Equal("bigger bolder", target.CssClass);
    }

    /// <summary>
    /// A test for ModifierConstructorTest2
    /// </summary>
    [Fact]
    public void Modifier_Constructor_Default() {
      Modifier target = new Modifier();

      Assert.Equal(String.Empty, target.ToolTip);
      Assert.Equal(String.Empty, target.Style);
      Assert.Equal(String.Empty, target.CssClass);
    }

    /// <summary>
    /// A test for ModifierConstructorTest1
    /// </summary>
    [Fact]
    public void Modifier_Constructor_ToolTip() {
      string toolTip = "text";
      Modifier target = new Modifier(toolTip);

      Assert.Equal(toolTip, target.ToolTip);
      Assert.Equal(String.Empty, target.Style);
      Assert.Equal(String.Empty, target.CssClass);
    }

    /// <summary>
    /// A test for ModifierConstructorTest
    /// </summary>
    [Fact]
    public void Modifier_Constructor_ToolTipCssClass() {
      string toolTip = "text";
      string cssClass = "bigger";
      Modifier target = new Modifier(toolTip, cssClass);

      Assert.Equal(toolTip, target.ToolTip);
      Assert.Equal(cssClass, target.CssClass);
      Assert.Equal(String.Empty, target.Style);
    }
  }
}
